//
//  JSWebCallbackManager.m
//  JSWebDemo
//
//  Created by ac-hu on 2018/7/7.
//  Copyright © 2018年 ac-hu. All rights reserved.
//

#import "JSWebCallbackManager.h"
#import "JSWebController.h"
#import "JSWebControllerManager.h"

@implementation JSWebCallbackManager
+(instancetype)share{
    static JSWebCallbackManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (manager == nil) {
            manager = [[JSWebCallbackManager alloc]init];
        }
    });
    return manager;
}

+(void)callBackStr:(NSString *)callBackStr backSuccessBlock:(JSWebCallbackSuccess)success{
    JSWebController * curVc = [JSWebControllerManager currentVC];
    [curVc.wkWebView evaluateJavaScript:callBackStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
        if (!error) {
            NSLog(@"回调成功%@",result);
            success(result);
        }else{
            NSLog(@"%@",error.description);
        }
    }];
}
@end
